using UnityEngine;
using System.Collections;

public class PickUpStuff : MonoBehaviour {

    public ConfigurableJoint joint;

    public bool hasItem = false;
    void Start()
    {
       
        
    }
   

	void Update()
	{
       

	}
    void FixedUpdate()
    {
    }

    public void DropItem()
    {
        
        joint.connectedBody.gameObject.layer = 1;

        Physics.IgnoreCollision(gameObject.transform.parent.collider, joint.connectedBody.collider, false);
        joint.connectedBody = null;
        hasItem = false;

    }

	void OnTriggerStay(Collider col)
	{
		
        
		//If moveable box and not have box
        if (col.collider.tag.Contains("Pickable"))
        {
            joint = GetComponent<ConfigurableJoint>();
            joint.connectedBody = col.collider.rigidbody;
            col.gameObject.layer = 2;
            Physics.IgnoreCollision(gameObject.transform.parent.collider, col.collider,true);
            hasItem = true;
        }
        //attach box
	}

	void OnDrawGizmosSelected()
	{
		
	}
}